]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowMenu: Implement new show_menu_for_rect() hook
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 2 Jun 2014 19:47:24 +0000 (21:47 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 2 Jun 2014 21:48:53 +0000 (23:48 +0200)
Having the full geometry of the menu's source button (if any) will
allow us to address several misbehaviors of window menus, so use
that instead of show_menu().

https://bugzilla.gnome.org/show_bug.cgi?id=731058

js/ui/windowManager.js
js/ui/windowMenu.js
src/gnome-shell-plugin.c
src/shell-wm-private.h
src/shell-wm.c

index 623619db6775c1bd669ea1279101c7ca672a695e..0b77916b06743f8dc4942316961d667b8b543f63 100644 (file)
@@ -1153,8 +1153,8 @@ const WindowManager = new Lang.Class({
         this._tilePreview.hide();
     },
 
-    _showWindowMenu: function(shellwm, window, menu, x, y) {
-        this._windowMenuManager.showWindowMenuForWindow(window, menu, x, y);
+    _showWindowMenu: function(shellwm, window, menu, rect) {
+        this._windowMenuManager.showWindowMenuForWindow(window, menu, rect);
     },
 
     _startAppSwitcher : function(display, screen, window, binding) {
index cca5504a40c9c74246e2591a2b4519048b9d697c..f993e15a2fc526ca4d4703f3b9cc845581f2ec24 100644 (file)
@@ -151,7 +151,7 @@ const WindowMenuManager = new Lang.Class({
         this._manager = new PopupMenu.PopupMenuManager({ actor: Main.layoutManager.dummyCursor });
     },
 
-    showWindowMenuForWindow: function(window, type, x, y) {
+    showWindowMenuForWindow: function(window, type, rect) {
         let menu = (type == Meta.WindowMenuType.WM) ? new WindowMenu(window)
                                                     : new AppMenu(window);
 
@@ -161,7 +161,7 @@ const WindowMenuManager = new Lang.Class({
             window.check_alive(global.get_current_time());
         });
 
-        Main.layoutManager.setDummyCursorGeometry(x, y, 0, 0);
+        Main.layoutManager.setDummyCursorGeometry(rect.x, rect.y, 0, 0);
         menu.open(BoxPointer.PopupAnimation.NONE);
         menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
         menu.connect('open-state-changed', Lang.bind(this, function(menu_, isOpen) {
index 4b78870f68b0e394fcd370518eed6c6cd667afbf..3c99c75d61b3b9200abbbe67c6ef5d2988a32efe 100644 (file)
@@ -78,6 +78,10 @@ static void gnome_shell_plugin_show_window_menu  (MetaPlugin         *plugin,
                                                   MetaWindowMenuType  menu,
                                                   int                 x,
                                                   int                 y);
+static void gnome_shell_plugin_show_window_menu_for_rect (MetaPlugin         *plugin,
+                                                          MetaWindow         *window,
+                                                          MetaWindowMenuType  menu,
+                                                          MetaRectangle      *rect);
 
 static gboolean              gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
                                                                XEvent     *event);
@@ -145,6 +149,7 @@ gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
   plugin_class->show_tile_preview = gnome_shell_plugin_show_tile_preview;
   plugin_class->hide_tile_preview = gnome_shell_plugin_hide_tile_preview;
   plugin_class->show_window_menu = gnome_shell_plugin_show_window_menu;
+  plugin_class->show_window_menu_for_rect = gnome_shell_plugin_show_window_menu_for_rect;
 
   plugin_class->xevent_filter     = gnome_shell_plugin_xevent_filter;
   plugin_class->keybinding_filter = gnome_shell_plugin_keybinding_filter;
@@ -318,6 +323,15 @@ gnome_shell_plugin_show_window_menu (MetaPlugin         *plugin,
   _shell_wm_show_window_menu (get_shell_wm (), window, menu, x, y);
 }
 
+static void
+gnome_shell_plugin_show_window_menu_for_rect (MetaPlugin         *plugin,
+                                              MetaWindow         *window,
+                                              MetaWindowMenuType  menu,
+                                              MetaRectangle      *rect)
+{
+  _shell_wm_show_window_menu_for_rect (get_shell_wm (), window, menu, rect);
+}
+
 static gboolean
 gnome_shell_plugin_xevent_filter (MetaPlugin *plugin,
                                   XEvent     *xev)
index c7068efa5c66612d9962faa075852d09dd89b211..9e44b33186ab81fbdcfbd81ec4f9ec3b9297b530 100644 (file)
@@ -45,6 +45,10 @@ void _shell_wm_show_window_menu      (ShellWM             *wm,
                                       MetaWindowMenuType   menu,
                                       int                  x,
                                       int                  y);
+void _shell_wm_show_window_menu_for_rect (ShellWM             *wm,
+                                          MetaWindow          *window,
+                                          MetaWindowMenuType   menu,
+                                          MetaRectangle       *rect);
 
 gboolean _shell_wm_filter_keybinding (ShellWM             *wm,
                                       MetaKeyBinding      *binding);
index 928f5f1046547626ece1722e89d97628793bd82b..67d03b8ccf0397bc6d93e56fd0c98d5fa12bc978 100644 (file)
@@ -141,8 +141,8 @@ shell_wm_class_init (ShellWMClass *klass)
                   G_TYPE_FROM_CLASS (klass),
                   G_SIGNAL_RUN_LAST,
                   0, NULL, NULL, NULL,
-                  G_TYPE_NONE, 4,
-                  META_TYPE_WINDOW, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
+                  G_TYPE_NONE, 3,
+                  META_TYPE_WINDOW, G_TYPE_INT, META_TYPE_RECTANGLE);
   shell_wm_signals[FILTER_KEYBINDING] =
     g_signal_new ("filter-keybinding",
                   G_TYPE_FROM_CLASS (klass),
@@ -303,7 +303,22 @@ _shell_wm_show_window_menu (ShellWM            *wm,
                             int                 x,
                             int                 y)
 {
-  g_signal_emit (wm, shell_wm_signals[SHOW_WINDOW_MENU], 0, window, menu, x, y);
+  MetaRectangle rect;
+
+  rect.x = x;
+  rect.y = y;
+  rect.width = rect.height = 0;
+
+  _shell_wm_show_window_menu_for_rect (wm, window, menu, &rect);
+}
+
+void
+_shell_wm_show_window_menu_for_rect (ShellWM            *wm,
+                                     MetaWindow         *window,
+                                     MetaWindowMenuType  menu,
+                                     MetaRectangle      *rect)
+{
+  g_signal_emit (wm, shell_wm_signals[SHOW_WINDOW_MENU], 0, window, menu, rect);
 }
 
 void